import cv2
import mediapipe as mp


class GestureRecognizer:
    def __init__(self):
        self.mp_hands = mp.solutions.hands  # 初始化MediaPipe手部解决方案
        self.hands = self.mp_hands.Hands()  # 创建手部关键点检测对象

    def recognize_gesture(self, frame):
        # 处理帧数据，检测手部关键点
        results = self.hands.process(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
        if results.multi_hand_landmarks:
            for hand_landmarks in results.multi_hand_landmarks:
                # 根据关键点分析手势（这里可以进一步开发）
                return hand_landmarks, "手势名称"
        return None, "未检测到手势"
